package butang.jvm.classloader.broken;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * ClassName: ClassLoaderTest
 * Package: butang.jvm.classloader.broken
 * Description:
 *
 * @Author BuTang
 * @Create 2024/1/20 16:37
 * @Version 1.0
 */
public class ClassLoaderTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        MyClassLoader myClassLoader = new MyClassLoader("butang.jvm.classloader.broken","D:\\Learning\\JVM\\jvm-testing-usage\\target\\classes\\butang\\jvm\\classloader\\broken\\");

        Class<?> clazz = myClassLoader.loadClass("A");
        System.out.println("加载A类的类加载器为"+clazz);

        System.out.println("加载A类的类加载器的父类为"+myClassLoader.getClass().getClassLoader());

        Method hello = clazz.getMethod("hello");
        hello.invoke(clazz.newInstance());
    }
}
